package com.love_weinuo.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * Created by Administrator on 2019/3/15.
 */

public class UUIDUtil {

    public static UUIDUtil instance;

    public static UUIDUtil getInstance(){
        if (instance == null) {
            instance = new UUIDUtil();
        }
        return instance;
    }

    public String getIdentity(Context context) {
        SharedPreferences preference = PreferenceManager.getDefaultSharedPreferences(context);
        String identity = preference.getString("identity", null);
        if (identity == null) {
            identity = java.util.UUID.randomUUID().toString();
            preference.edit().putString("identity", identity);
        }
        return identity;
    }

}
